package org.javaboy.sms_login.controller;

import com.aliyun.auth.credentials.Credential;
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
import com.aliyun.sdk.service.dysmsapi20170525.AsyncClient;
import com.aliyun.sdk.service.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.sdk.service.dysmsapi20170525.models.SendSmsResponse;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.gson.Gson;
import darabonba.core.client.ClientOverrideConfiguration;
import jakarta.servlet.http.HttpSession;
import org.javaboy.sms_login.service.SendSmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.SecureRandom;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

@RestController
public class LoginController {


    @Autowired
    SendSmsService sendSmsService;

    /**
     * 这个就是发送短信的接口，当前端点击发送验证码按钮之后，就会请求这个方法，然后在这个方法中去发短信
     */
    @GetMapping("/sendSms")
    public void sendSms(HttpSession session, String phone) throws ExecutionException, InterruptedException, JsonProcessingException {
        sendSmsService.sendSms(phone, session);
    }
}
